﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TierService;
using TierApplication;

namespace OrderMgr.Rpt
{
    class OrderFunc
    {
        public static void QueryOrder(string sOrderID)
        {
            T_Order mOrder = new T_Order();
            mOrder.GetModel(sOrderID);

            Utility.OrderType OrderType;
            OrderType = (Utility.OrderType)(int.Parse(mOrder.OrderType));

            switch (OrderType)
            {
                case Utility.OrderType.Sale:
                    Rpt.frmRptSaleDetail fDetail = new frmRptSaleDetail();
                    fDetail._OrderID = sOrderID;
                    fDetail._OrderType = OrderType;
                    fDetail.ShowDialog();
                    break;
                case Utility.OrderType.Buy:
                    OrderInfo.frmBuysDetail BuysDetail = new OrderInfo.frmBuysDetail();
                    BuysDetail.OpMode = Utility.OperateMode.Query;
                    BuysDetail._OrderID = sOrderID;
                    BuysDetail._OrderType = OrderType;
                    BuysDetail.ShowDialog();
                    break;
                case Utility.OrderType.BuyToStock:
                    OrderInfo.frmBuyToStockDetail BuyToStock = new OrderInfo.frmBuyToStockDetail();
                    BuyToStock.OpMode = Utility.OperateMode.Query;
                    BuyToStock._OrderID = sOrderID;
                    BuyToStock._OrderType = OrderType;
                    BuyToStock.ShowDialog();
                    break;
                case Utility.OrderType.BuyCancelStock:
                    OrderInfo.frmBuyCancelStockDetail BuyCancelStock = new OrderInfo.frmBuyCancelStockDetail();
                    BuyCancelStock.OpMode = Utility.OperateMode.Query;
                    BuyCancelStock._OrderID = sOrderID;
                    BuyCancelStock._OrderType = OrderType;
                    BuyCancelStock.ShowDialog();
                    break;
                case Utility.OrderType.SaleCancel:
                    OrderInfo.frmSaleCancelDetail SaleCancelDetail = new OrderInfo.frmSaleCancelDetail();
                    SaleCancelDetail.OpMode = Utility.OperateMode.Query;
                    SaleCancelDetail._OrderID = sOrderID;
                    SaleCancelDetail._OrderType = OrderType;
                    SaleCancelDetail.ShowDialog();
                    break;
                case Utility.OrderType.StockTake:
                    OrderInfo.frmStockTakeDetail StockTakeDetail = new OrderInfo.frmStockTakeDetail();
                    StockTakeDetail.OpMode = Utility.OperateMode.Query;
                    StockTakeDetail._OrderID = sOrderID;
                    StockTakeDetail._OrderType = OrderType;
                    StockTakeDetail.ShowDialog();
                    break;
                case Utility.OrderType.Transfer:
                    OrderInfo.frmTransferDetail TransferDetail = new OrderInfo.frmTransferDetail();
                    TransferDetail.OpMode = Utility.OperateMode.Query;
                    TransferDetail._OrderID = sOrderID;
                    TransferDetail._OrderType = OrderType;
                    TransferDetail.ShowDialog();
                    break;
                case Utility.OrderType.Wastage:
                    OrderInfo.frmWastageDetail WastageDetail = new OrderInfo.frmWastageDetail();
                    WastageDetail.OpMode = Utility.OperateMode.Query;
                    WastageDetail._OrderID = sOrderID;
                    WastageDetail._OrderType = OrderType;
                    WastageDetail.ShowDialog();
                    break;

                case Utility.OrderType.Borrow:
                    OrderInfo.frmBuysDetail fBorrowDetail = new OrderInfo.frmBuysDetail();
                    fBorrowDetail.OpMode = Utility.OperateMode.Query;
                    fBorrowDetail._OrderID = sOrderID;
                    fBorrowDetail._OrderType = OrderType;
                    fBorrowDetail.ShowDialog();
                    break;
                case Utility.OrderType.BorrowToStock:
                    OrderInfo.frmBuyToStockDetail BorrowToStockDetail = new OrderInfo.frmBuyToStockDetail();
                    BorrowToStockDetail.OpMode = Utility.OperateMode.Query;
                    BorrowToStockDetail._OrderID = sOrderID;
                    BorrowToStockDetail._OrderType = OrderType;
                    BorrowToStockDetail.ShowDialog();
                    break;
                case Utility.OrderType.BorrowSendBack:
                    OrderInfo.frmSaleShipStockDetail BorrowSendBackDetail = new OrderInfo.frmSaleShipStockDetail();
                    BorrowSendBackDetail.OpMode = Utility.OperateMode.Query;
                    BorrowSendBackDetail._OrderID = sOrderID;
                    BorrowSendBackDetail._OrderType = OrderType;
                    BorrowSendBackDetail.ShowDialog();
                    break;
                case Utility.OrderType.Loan:
                    OrderInfo.frmSalesDetail LoanDetail = new OrderInfo.frmSalesDetail();
                    LoanDetail.OpMode = Utility.OperateMode.Query;
                    LoanDetail._OrderID = sOrderID;
                    LoanDetail._OrderType = OrderType;
                    LoanDetail.ShowDialog();
                    break;
                case Utility.OrderType.LoanStock:
                    OrderInfo.frmSaleShipStockDetail LoanStockDetail = new OrderInfo.frmSaleShipStockDetail();
                    LoanStockDetail.OpMode = Utility.OperateMode.Query;
                    LoanStockDetail._OrderID = sOrderID;
                    LoanStockDetail._OrderType = OrderType;
                    LoanStockDetail.ShowDialog();
                    break;
                case Utility.OrderType.LoanReturnBackToStock:
                    OrderInfo.frmBuyToStockDetail LoanReturnBackToStockDetail = new OrderInfo.frmBuyToStockDetail();
                    LoanReturnBackToStockDetail.OpMode = Utility.OperateMode.Query;
                    LoanReturnBackToStockDetail._OrderID = sOrderID;
                    LoanReturnBackToStockDetail._OrderType = OrderType;
                    LoanReturnBackToStockDetail.ShowDialog();
                    break;
                default:
                    break;
            }


        }
    }
}
